<template>
  <Table class="custom-ivu-table" border :columns="internal_columns" :data="tableData"></Table>
</template>

<script>
import { getColumns } from './service'
// import $bus from '@/utils/bus'

import mixin from './mixin'
export default {
  name: 'UnexecuteExpandRow',

  mixins: [mixin],

  props: {
    row: Object,
    columns: Array,
  },

  data() {
    const vm = this
    return {
      internal_columns: [],
      tableData: [],
      oper_columns: {
        title: '超时督办',
        align: 'center',
        render(h, params) {
          return (
            <i-button
              type="primary"
              disabled={params.row.supervise}
              nativeOnClick={() => {
                vm.handleSupervise_unexecute(params.row)
              }}
            >
              {params.row.supervise ? '已督办' : '督办'}
            </i-button>
          )
        },
      },
      prefix_columns: [
        {
          width: 50,
          render: (h, params) => {
            return h('')
          },
        },
      ],
    }
  },

  watch: {
    row: {
      handler(v) {
        // console.log('vvvv', v)
        const data = v.list || []
        if (!data.length) return
        this.tableData = Object.freeze(data)
        const a = getColumns(this.columns).concat(this.oper_columns)
        this.internal_columns = this.prefix_columns.concat(a)
      },
      immediate: true,
    },
  },

  methods: {
    handleSupervise_unexecute(row) {
      // $bus.$emit('on-get-command-detail')
      // console.log('row', row.detailId)
      this.postCommandSupervise({ ids: row.detailId })
    },
  },

  /* mounted() {
    console.log(this)
  }, */
}
</script>

<style lang="less" scoped></style>
